package com.learn.ioc.xml;

import com.learn.ioc.bean.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 通过ClassPathXmlApplication方式 读入
 *
 * @Author ganquanzhong
 * @Date 2019/12/27 0:22
 */
public class XmlBeanTest {
	public static void main(String[] args){
		ApplicationContext ac = new ClassPathXmlApplicationContext("spring-bean01.xml");

		for (String beanDefinitionName : ac.getBeanDefinitionNames()) {
			System.out.println(beanDefinitionName);
		}

		User user = (User)ac.getBean("user");
		System.out.println(user.toString());
	}

}
/* Output:
调用了自定义的BeanFactoryPostProcessor org.springframework.beans.factory.support.DefaultListableBeanFactory@1554909b: defining beans [user,a,b,myBeanFactoryPostProcessor]; root of factory hierarchy
BeanDefinitionName：user
user bean properties（Bean的属性值）:  PropertyValues: length=4; bean property 'uid'; bean property 'username'; bean property 'pwd'; bean property 'addr'
BeanDefinitionName：a
a bean properties（Bean的属性值）:  PropertyValues: length=1; bean property 'b'
BeanDefinitionName：b
b bean properties（Bean的属性值）:  PropertyValues: length=1; bean property 'a'
BeanDefinitionName：myBeanFactoryPostProcessor
myBeanFactoryPostProcessor bean properties（Bean的属性值）:  PropertyValues: length=0
【user-afterPropertiesSet】-实现InitializingBean接口的afterPropertiesSet方法，在bean初始化会自动调用该方法！
【user-initMethod】-在bean被spring容器初始化时，会执行initMethod属性指定的方法！
user
a
b
myBeanFactoryPostProcessor
User{uid=2020101, username='甘全中-gqzdev', pwd='***888', tel='null', addr='china'}
*///~